//当前模块，API进行统一管理，即对请求接口统一管理
import requests from '@/api/request';
import mockRequests from '@/api/mockRequest';

//首页三级分类接口
export const reqCateGoryList = () => requests.get('/product/category/list/tree')

//获取mock banner数据
export const reqGetBannerList = () => mockRequests.get('/banner')

//获取floor数据
export const reqGetFloorList = () => mockRequests.get('/floor')

//获取搜索模块的数据 /api/list 请求方式:post
/*
{
    "category3ld": "61",
    "categoryName": "手机",
    "keyword": "小米",
    "order": "1:desc",
    "pageNo": 1,
    "pageSize": 10,
    "props": ["1:1700-2799:价格", "2:6.65-6.74 英寸:屏幕尺寸"],
    "trademark": "4:小米"
}
*/
//当前这个函数需不需要接受外部传递参数
//当前这个接口（获取搜索模块的数据），给服务器传递一个默认参数【至少是一个空对象】
export const reqGetSearchInfo = (params) => requests({url: "/search/list", method: "post", data: params})

//获取商品详情信息
export const reqGoodsInfo = (skuId) => requests({url: `/product/item/${skuId}`, method: "get"})
export const reqMockGoodsInfo = (skuId) => mockRequests({url: `/item/${skuId}`, method: "get"})

//加入购物车
export const addToCart = (skuId, skuNum) => requests({
  url: `/cart/addToCart/${skuId}/${skuNum}`,
  method: "get"
})

//获取购物车列表数据接口
export const reqCartList = () => requests({url: "/cart/getCartList", method: "get"})

//删除购物车商品的接口
export const reqDeleteCartById = (skuId) => requests({url: `/cart/deleteCartItem/${skuId}`, method: "get"})

//修改购物项的勾选状态
export const reqUpdateCheckedById = (skuId, isChecked) => requests({
  url: `/cart/checkCart/${skuId}/${isChecked}`,
  method: "get"
})

//修改购物项的数量
export const reqChangeNum = (skuId, num) => requests({
  url: `/cart/changeNum/${skuId}/${num}`,
  method: "get"
})

//获取验证码
export const reqGetCode = (params) => requests({url: `/auth/sms/sendcode`, method: "get", params})

//注册
export const reqUserRegister = (data) => requests({url: `/auth/regist2`, data, method: "post"})

//登录
export const reqUserLogin = (data) => requests({url: `/auth/login2`, data, method: "post"})

//获取用户信息
export const reqUserInfo = () => requests({url: `/auth/verify`, method: "get"})

//退出登录
export const reqLogout = () => requests({url: `/auth/logout2`, method: "get"})

//获取用户地址信息
export const reqAddressInfo = () => requests({url: `/user/userAddress/auth/findUserAddressList`, method: "get"})

//获取确认订单信息
export const reqOrderConfirmInfo = () => requests({url: `/order/confirm`, method: "get"})

//获取运费信息
export const reqFareInfo = (params) => requests({url: `/ware/wareinfo/fare`, method: "get", params})

//提交订单
export const reqSubmitOrder = (data) => requests({
  url: `/order/submitOrder`,
  data,
  method: "post"
})

//获取支付信息
export const reqPayInfo = (orderId) => requests({url: `/payment/weixin/createNative/${orderId}`, method: "get"})

//支付宝支付
export const alipay = (params) => requests({url: `/order/aliPayOrder`, method: "get", params})

//获取订单的支付状态
export const reqPayStatus = (orderId)=> requests({url: `/payment/weixin/queryPayStatus/${orderId}`, method: "get"})

//获取我的订单数据
export const reqMyOrderList = (params) => requests({url: `/member/order`, method: "get", params})

//查询当前秒杀商品信息
export const reqCurrentSeckillSkus = () => requests({url: `/seckill/currentSeckillSkus`, method: "get"})

//立即秒杀
export const reqKillNow = (params) => requests({url: `/seckill/kill`, method: "get", params})
